﻿// Added UserManager class 
// S.E.KHOR

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    /// <summary>
    /// User related class
    /// </summary>
    public class UserManager
    {
        
        FingerVeinEntities _dbContext = new FingerVeinEntities();

        /// <summary>
        /// Retrieve all users
        /// </summary>
        /// <returns></returns>
        public List<USER_TABLE> GetUsers()
        {

            List<USER_TABLE> result = (from a in _dbContext.USER_TABLE
                                       select a).ToList<USER_TABLE>();
            return result;


        }

        /// <summary>
        /// Save and update of user
        /// </summary>
        /// <param name="user"></param>
        public void SaveUser(USER_TABLE user)
        {
            _dbContext.Entry(user).State = user.User_ID == 0 ?
                EntityState.Added : EntityState.Modified;
            _dbContext.SaveChanges();

        }
    }
}
